from time import sleep

from selenium import  webdriver
driver=webdriver.Firefox()
driver.get('https://www.baidu.com/')

driver.find_element_by_partial_link_text('新闻').click()
sleep(3)

hds = driver.window_handles

driver.switch_to.window(hds[1])

driver.find_element_by_partial_link_text('军事').click()
sleep(3)

driver.find_element_by_partial_link_text('武警').click()
sleep(2)

driver.switch_to.window(hds[1])

driver.close()

driver.switch_to.window(hds[0])
sleep(2)

key_word=driver.find_element_by_id('kw')
key_word.send_keys('selenium')
bt=driver.find_element_by_id('su')
bt.click()
sleep(3)

driver.quit()


